<!DOCTYPE html>
<head>
<title>test proxied ws connection</title>
</head>
<script type="text/javascript">
// Do connection test and check the headers arrive at the WebSocket.

var protocol = location.protocol.replace('http', 'ws');
var url = protocol + '//' + location.host + '/echo-request-headers';
var ws = new WebSocket(url);

ws.onmessage = function(evt)
{
  var headers = JSON.parse(evt.data);
  for (var name in headers) {
    // The keys in the serialized data are lower cased.
    if (name.startsWith('proxy-')) {
      document.title = 'FAIL';
      return;
    }
  }

  // Set document title to 'PASS'. The test observer catches this title changes
  // to know the result.
  document.title = 'PASS';
}

ws.onclose = function()
{
  document.title = 'FAIL';
}
</script>
